#pragma once;
#pragma warning(disable:4267)
#include "stdio.h"
#include "windows.h"
#include "iostream"
#include "memory"
#include "deque"
#include "Angel.h"
#include <string>
using namespace std;
extern HDC debughdc[5];
#define DebugWnd_GameDebug 0
#define DebugWnd_OpenGL 1
#define DebugWnd_Camera 2
#define DebugWnd_other 3
class Debug
{
private:
	  static const int FrameFrequence=300;  
	  int state[4];
	  int limit[4];
public: 
	bool isOutDebug;
	static const int COLOR_BLUE=9,COLOR_RED=12,COLOR_YELLOW=14,COLOR_WHITE=15,COLOR_PINK=13;
	void static set_console_color(unsigned short color_index)
    {
    SetConsoleTextAttribute(GetStdHandle((DWORD)-11), color_index);
    }
	void static OutInfo( int Color,const char *tem)
	{
		set_console_color(Color);
		cout<<tem<<endl;
		set_console_color(COLOR_WHITE);
	}
	void OutInfo(int Color,const char *tem,int i)
	{
		set_console_color(Color);
		cout<<tem;
		set_console_color(COLOR_WHITE);
	}
	Debug()
	{
		memset(state,0,sizeof(state));
		int limittem[4]={20,20,3,3};
		memcpy(limit,limittem,4*sizeof(int));
		isOutDebug=true;
	}
	void ShowMatrix(int hdc,int x,int y,mat4 tem)
    {
		if (!isOutDebug)
			return;
	    int i;
	    char temp[4][1000];
		for (i=0;i<4;i++)
		{
			sprintf_s(temp[i],"%.2f  %.2f  %.2f  %.2f    ",tem[i][0],tem[i][1],tem[i][2],tem[i][3]);
			TextOutA(debughdc[hdc],x,y+20*(i),temp[i],strlen(temp[i]));
		}
    }
	void ShowMatrix(int hdc,int x,int y,mat4 tem,const char *ch)
    {
		if (!isOutDebug)
			return;
	    int i;
	    char temp[4][1000];
		TextOutA(debughdc[hdc],x,y,ch,strlen(ch));
		for (i=0;i<4;i++)
		{
			sprintf_s(temp[i],"%.2f  %.2f  %.2f  %.2f    ",tem[i][0],tem[i][1],tem[i][2],tem[i][3]);
			TextOutA(debughdc[hdc],x,y+20*(i+1),temp[i],strlen(temp[i]));
		}
    }
	void Reset()
	{
		memset(state,0,sizeof(state));
	}
	void AddMessage(int hdc,char ch[])
	{
		if (!isOutDebug)
			return;
		TextOutA(debughdc[hdc],0,state[hdc]*20,ch,strlen(ch));
	    state[hdc]++;
		if (state[hdc]>=limit[hdc])
			state[hdc]=0;
	}	
	void ShowVec4(int hdc,int x,int y,vec4 tem,char *ch)
	{
		if (!isOutDebug)
			return;
		char temp[1000];
		TextOutA(debughdc[hdc],x,y,ch,strlen(ch));
		sprintf_s(temp,"%.2f  %.2f  %.2f  %.2f    ",tem[0],tem[1],tem[2],tem[3]);
	    TextOutA(debughdc[hdc],x,y+20,temp,strlen(temp));
	}
	void Show(int hdc,int x,int y,float tem,char *ch)
	{
		if (!isOutDebug)
			return;
		char temp[1000];
		sprintf_s(temp,"%s: %.2f",ch,tem);
	    TextOutA(debughdc[hdc],x,y+20,temp,strlen(temp));
	}
	void Show(int hdc,int x,int y,char *temp)
	{
	    TextOutA(debughdc[hdc],x,y,temp,strlen(temp));
	}
};